SEGS = 12
STEPS = 6
ROT_ADJUST = radians 180 / SEGS
INTERVAL = TWO_PI / SEGS
SHADE, TINT = 0, 1

def setup
  size 200, 200
  background 127
  smooth
  ellipseMode CENTER_RADIUS
  noStroke
  create_wheel width/2, height/2, SHADE
end

def create_wheel(x, y, value_shift)
  radius = 95
  seg_width = radius / STEPS
  draw_proc = Proc.new do |j|
    c = j * 255.0 / STEPS
    [
      color(c, c, 0), 
      color(c, c/1.5, 0), 
      color(c, c/2, 0), 
      color(c, c/2.5, 0), 
      color(c, 0, 0), 
      color(c, 0, c/2), 
      color(c, 0, c), 
      color(c/2, 0, c), 
      color(0, 0, c),
      color(0, c, c/2.5), 
      color(0, c, 0), 
      color(c/2, c, 0) 
    ].each_with_index do |col, i|
      fill col
      arc x, y, radius, radius,
          i*INTERVAL+ROT_ADJUST,
          (i+1)*INTERVAL+ROT_ADJUST
    end
    radius -= seg_width
  end
  
  case value_shift
  when SHADE
    STEPS.downto 0, &draw_proc
  when TINT
    STEPS.times &draw_proc
  end
end